#pragma once

#include "mybaseframe.h"
#include <wx/webview.h>

class MyWebFrame;

#define USE_WEB_DLG 1

class MyWebFrame 
#ifdef USE_WEB_DLG
	: public wxDialog
#else
	: public wxFrame
#endif
	, public zqdb::SkinMap<MyWebFrame, SkinInfo>
{
#ifdef USE_WEB_DLG
	typedef wxDialog Base;
#else
	typedef wxFrame Base;
#endif
	typedef zqdb::SkinMap<MyBaseFrame, SkinInfo> SkinBase;
protected:
	wxWebView* m_browser;
public:
	MyWebFrame(const char* xml, size_t xmlflag, wxWindow* parent = nullptr);
	virtual ~MyWebFrame();

	int FilterEvent(wxEvent& event);

	void LoadURL(const wxString& url);
	wxString GetURL();
	
	void OnSkinInfoChanged();
	
protected:
	//
	void OnActivateEvent(wxActivateEvent& event);
	void OnCloseEvent(wxCloseEvent& event);
	void OnNavigationRequest(wxWebViewEvent& evt);
	void OnNavigationComplete(wxWebViewEvent& evt);
	void OnDocumentLoaded(wxWebViewEvent& evt);
	void OnNewWindow(wxWebViewEvent& evt); 
	void OnTitleChanged(wxWebViewEvent& evt);
	void OnError(wxWebViewEvent& evt);
	wxDECLARE_EVENT_TABLE();
};

